/*
 * @Author       : wfl
 * @LastEditors: fj
 * @description  :
 * @updateInfo   :
 * @Date         : 2022-12-15 09:52:50
 * @LastEditTime: 2023-05-31 12:24:02
 */
import type { Ref } from 'vue'
import type { ISearchForm } from '@/global/enums/search'
import { EFormType } from '@/global/enums/search'
export const useFields = (datasourceDict: any) => {
  const tableKeys: Ref<ISearchForm[]> = ref([])
  const defKeys = useTableKey()
  const fieldList: Ref<ISearchForm[]> = ref([
    {
      key: 'name',
      value: '',
      label: '连接名称',
      show: true,
      search: true
    },
    {
      key: 'type',
      value: '',
      label: '数据库类型',
      width: 100,
      type: EFormType.select,
      options: datasourceDict,
      show: true,
      search: true
    },
    {
      key: 'ip',
      value: '',
      label: 'ip',
      width: 140,
      show: true,
      search: true
    },
    {
      key: 'port',
      value: '',
      label: '端口',
      show: true,
      width: 100,
      search: true
    }, {
      key: 'schemaName',
      value: '',
      label: '数据库名称',
      show: true,
      search: true
    }, {
      key: 'driverClassName',
      value: '',
      label: '驱动类名',
      show: true
    }, {
      key: 'remark',
      value: '',
      label: '描述',
      show: true,
      width: 150
    },
    ...defKeys,
    {
      key: '',
      value: '',
      label: '操作',
      show: true,
      width: 106,
      fixed: 'right',
      tableSlot: 'operate'
    }
  ])

  return {
    fieldList,
    tableKeys
  }
}
